<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
#accountInfo .box-header {
	padding: 19px;
}

#statistics .box-title {
	font-size: 16px;
}

#vol p:nth-child(2) {
	font-size: 15px;
}

select {
	color: black;
}

.ui-autocomplete-input {
	width: 100%;
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div class="full-center-content-scroll-noheader ">
			<h:form id="form">
				<p:growl id="msgs" showDetail="true" />
				<p:toolbar id="btnBar">
					<f:facet name="left">
						<p:commandButton value="编辑" id="editBtn"
							disabled="#{alarmReceiveRoleController.selectMsgType.getId()==null}" oncomplete="PF('editDlg').show()"
							rendered="#{s:hasPermission(session,'xtsz_xtzd_gjdxsz_bj')}"
							process="@this" actionListener="#{alarmReceiveRoleController.preEdit()}"
							update="editForm" icon="fa fa-pencil" />
						<p:commandButton value="移除角色" id="delBtn"
							disabled="#{alarmReceiveRoleController.selectMsgType.getId()==null}"
							rendered="#{s:hasPermission(session,'xtsz_xtzd_gjdxsz_ycjs')}"
							actionListener="#{alarmReceiveRoleController.delete()}"
							update="form:msgs form:configTb form:delBtn form:editBtn" icon="fa fa-trash">
							<p:confirm header="提示" message="确定要移除所有角色么？" icon="ui-icon-alert" />
						</p:commandButton>
					</f:facet>
				</p:toolbar>
				<p:dataTable id="configTb" var="record" emptyMessage="无记录" 
					value="#{alarmReceiveRoleController.msgTypes}" rowKey="#{record.id}"
					paginator="true" paginatorPosition="bottom"
					paginatorTemplate="{Customertion} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rows="20" rowsPerPageTemplate="20,50,100" rowIndexVar="ite"
					selection="#{alarmReceiveRoleController.selectMsgType}"
					style="margin-bottom:20px;text-align: center">
					<f:facet name="{Customertion}">
             			<p:outputLabel value="总计：#{alarmReceiveRoleController.msgTypes.size()}条纪录" style="margin-right:20px"/>
             		</f:facet>
					<p:ajax event="rowSelectRadio" update="form:btnBar " />
					<p:column selectionMode="single" style="width:60px" />
					<p:column headerText="序号" style="width:64px;">
						<h:outputText value="#{ite+1}" />
					</p:column>
					<p:column headerText="消息类型" style="width:30%;">
						<h:outputText value="#{record.name}"  />
					</p:column>
					<p:column headerText="短信接收角色" style="width:50%;">
						<p:repeat var="role" value="#{alarmReceiveRoleController.getAllReceiveRole(record)}">
							<div style="float:left;">
								<h:outputText value="#{role}" style="margin-left:5px;" />
								<p:commandLink title="移除角色" styleClass="ui-commandlink-fa ui-widget-fa fa fa-remove" 
									style="margin-left:5px;color:red" update="form:configTb form:msgs"
									actionListener="#{alarmReceiveRoleController.removeReceiveRole(role,record)}" >
									<p:confirm header="提示" message="确定移除该角色吗?" icon="ui-icon-alert" />
								</p:commandLink>  
							</div>
						</p:repeat>
					</p:column>
					<p:column headerText="上级部门角色人员是否接收短信" style="width:20%;">
						<h:outputText value="#{alarmReceiveRoleController.findReceiveType(record)}" />
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="editForm">
				<p:dialog id="editDlg" widgetVar="editDlg" modal="true" width="600" header="编辑"
					height="400">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" style="float: right;" icon="fa fa-floppy-o" id="saveBtn"
								update="form:configTb form:msgs form:delBtn form:editBtn"
								actionListener="#{alarmReceiveRoleController.save()}" oncomplete="PF('editDlg').hide()" />
						</f:facet>
					</p:toolbar>
					<p:outputPanel id="editDetail">
						<p:panelGrid columns="2" style="width:100%">
							<h:outputText value="消息类型：" />
							<p:outputLabel value="#{alarmReceiveRoleController.alarmReceiveRole.name}" />
							<h:outputText value="短信接收角色：" />
							<p:selectManyCheckbox value="#{alarmReceiveRoleController.selectRoles}" layout="grid" columns="3" >
						        <f:selectItems value="#{alarmReceiveRoleController.allRoles}" var="r" itemLabel="#{r.name}" itemValue="#{r.id}" />
						    </p:selectManyCheckbox>
							<h:outputText value="上级部门角色人员是否接收短信：" />
							<p:selectOneButton value="#{alarmReceiveRoleController.alarmReceiveRole.allReceive}">
					            <f:selectItem itemLabel="是" itemValue="true" />
					            <f:selectItem itemLabel="否" itemValue="false" />
					        </p:selectOneButton>
						</p:panelGrid>
					</p:outputPanel>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/plugins/datatables/jquery.dataTables.js"></script>
		<script src="/resources/plugins/datatables/dataTables.bootstrap.min.js"></script>
		<script src="/resources/js/tables/mytable.js"></script>
		<script src="/resources/js/mymodal.js"></script>
	</ui:define>
</ui:composition>
